package com.vision.sales.sv.report;

import com.vision.sales.cm.db.data.Customer;
import com.vision.sales.cm.db.data.DeliveryReceipt;

/**
 * 
 * @author Mark
 *
 */
public class DeliveryReceiptRow implements Comparable<DeliveryReceiptRow> {

	private DeliveryReceipt deliveryReceipt;
	
	public DeliveryReceiptRow() {
	}
	
	public DeliveryReceiptRow(DeliveryReceipt deliveryReceipt) {
		this.deliveryReceipt = deliveryReceipt;
	}

	public DeliveryReceipt getDeliveryReceipt() {
		return this.deliveryReceipt;
	}
	public Customer getCustomer() {
		return this.deliveryReceipt.getCustomer();
	}

	public Object get(String column) {
		
		if ("date".equals(column)) 
			return this.deliveryReceipt.getDate();
			
		if ("drNo".equals(column))
			return this.deliveryReceipt.getDrNo();
			
		if ("customer".equals(column)) // assumption: customer is never null
			return this.deliveryReceipt.getCustomer().getName();
		
		if ("invoice".equals(column) && this.deliveryReceipt.getSalesInvoice() != null)
			return this.deliveryReceipt.getSalesInvoice().getInvoiceNo();
		
		return "";
	}
	
	@Override
	public int compareTo(DeliveryReceiptRow r) {
		return this.deliveryReceipt.getDrNo().compareToIgnoreCase(r.getDeliveryReceipt().getDrNo());
	}

}
